home *** CD-ROM | disk | FTP | other *** search
- <?php
- /*
- ** $Id: tools_backup.php,v 1.6 2005/04/05 11:05:20 hmailserver Exp $
- **
- ** hMailServer - Web interface
- **
- ** File formatted using TAB size 4
- **
- ** Get hMailserver at http://www.hmailserver.com
- **
- ** Author: Steen Rab°l <srabol@mail.tele.dk>
- ** Copyright (c) 2004, Steen Rab°l <srabol@mail.tele.dk>
- **
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; either version 2 of the License, or
- ** (at your option) any later version.
- **
- ** You may not change or alter any portion of this comment or credits
- ** of supporting developers from this source code or any supporting
- ** source code which is considered copyrighted (c) material of the
- ** original comment or credit authors.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- **
- */
-
- if (hmailGetAdminLevel() != 2)
- hmailHackingAttemp();
-
- require_once("include/minixml/minixml.inc.php");
- $function = hmailGetVar("function");
-
- if($function == "dobackup")
- {
- $output = array();
- $dodomains = hmailGetVar("dodomains","");
- $doaccounts = hmailGetVar("doaccounts","");
- $doaliases = hmailGetVar("doaliases","");
- $dodistributionlists = hmailGetVar("dodistributionlists","");
- $dodistrecipients = hmailGetVar("dodistrecipients","");
- $dosettings = hmailGetVar("dosettings","");
- $filename = hmailGetVar("filename","");
- $dodownload = hmailGetVar("dodownload","");
- $xmlDoc = new MiniXMLDoc();
- $xmlRoot = &$xmlDoc->getRoot();
- $xmlArray = array();
- $obDomains = $obBaseApp->Domains();
- $DomainCount = $obDomains->Count();
-
- if($dodomains != "")
- {
- $output[] = array("log" => "Backing up domains");
- $xmlDomainsRoot = &$xmlRoot->CreateChild("Domains");
- $xmlDomainsRoot->attribute('count',$DomainCount);
- for ($i = 1; $i <= $DomainCount; $i++)
- {
- $obDomain = $obBaseApp->Domains[$i-1];
- $output[] = array("log" => "Backing up domain: " . $obDomain->Name);
- $xmlDomainRoot = &$xmlDomainsRoot->CreateChild("Domain");
- $xmlDomainRoot->attribute("id",intval($i));
- $e = &$xmlDomainRoot->createChild("Name");
- $e->text($obDomain->Name);
- $e = &$xmlDomainRoot->createChild("Active");
- $e->text(($obDomain->Active == true ? 1 : 0));
- $e = &$xmlDomainRoot->createChild("Postmaster");
- $e->text($obDomain->Postmaster);
-
- if($doaccounts != "")
- {
- BackupAccounts($xmlDomainRoot,$obDomain);
- } // end if accounts
- if($doaliases != "")
- {
- BackupDomainAliases($xmlDomainRoot,$obDomain);
- } // end if aliases
-
- if($dodistributionlists != "")
- {
- BackupDistributionLists($xmlDomainRoot,$obDomain,$dodistrecipients);
- } // end if dodistributionlists
- }
- }
-
- if($dosettings !=="")
- {
- BackupSettings($xmlRoot,$obBaseApp);
- }
-
- $xml = $xmlDoc->toString(1);
- $hmailSmarty->assign("xml",htmlentities($xml));
- $hmailSmarty->assign("output",$output);
- $hmailSmarty->assign("pagecontent",$hmailSmarty->fetch('tools_backup_complete.tpl'));
- }
- else
- {
- $hmailSmarty->assign("pagecontent", $hmailSmarty->fetch('tools_backup.tpl'));
- }
-
- function BackupDomain($p_xmlroot,$p_domainid, $p_options)
- {
- }
-
- function BackupDistributionListRecipients(&$p_xmlroot,&$p_distributionlist)
- {
- global $hmailSmarty, $output;
- $output[] = array("log" => "Backing up dlist recipients");
- $obRecipients = $p_distributionlist->Recipients();
- $rCount = $obRecipients->Count();
- if($rCount)
- {
- $xmlroot_recipeients = &$p_xmlroot->createChild("Recipients");
- $xmlroot_recipeients->attribute("count",$rCount);
- for ($i = 0; $i < $rCount; $i++)
- {
- $obRecipient = $obRecipients->Item($i);
- $xmlroot_recipeient = &$xmlroot_recipeients->createChild("Recipient");
- $xmlroot_recipeient->attribute("id",$i+1);
- $xmlroot_recipeient_elm = &$xmlroot_recipeient->createChild("RecipientAddress");
- $xmlroot_recipeient_elm->text($obRecipient->RecipientAddress);
- }
- }
- }
-
- function BackupDistributionLists(&$p_xmlroot,&$p_domain,$p_recipients = true)
- {
- global $hmailSmarty,$output;
-
- $output[] = array("log" => "Backing up dlist distributionlists");
- $obDistributionLists = $p_domain->DistributionLists();
- $Count = $obDistributionLists->Count();
- if($Count)
- {
- $xmlroot_distributionlists = &$p_xmlroot->createChild("DistributionLists");
- $xmlroot_distributionlists->attribute("count",$Count);
- for ($i = 0; $i < $Count; $i++)
- {
- $obDistributionList = $obDistributionLists->Item($i);
-
- $xmlroot_distributionlist = &$xmlroot_distributionlists->createChild("DistributionList");
- $xmlroot_distributionlist->attribute("id",($i+1));
- $xmlroot_distributionlist_elm = &$xmlroot_distributionlist->createChild("Active");
- $xmlroot_distributionlist_elm->text(($obDistributionList->Active ? "1" : "0"));
- $xmlroot_distributionlist_elm = &$xmlroot_distributionlist->createChild("Address");
- $xmlroot_distributionlist_elm->text($obDistributionList->Address);
- $xmlroot_distributionlist_elm = &$xmlroot_distributionlist->createChild("RequireSMTPAuth");
- $xmlroot_distributionlist_elm->text(($obDistributionList->RequireSMTPAuth ? "1" : "0"));
- $xmlroot_distributionlist_elm = &$xmlroot_distributionlist->createChild("RequireSenderAddress");
- $xmlroot_distributionlist_elm->text($obDistributionList->RequireSenderAddress);
-
- if($p_recipients != "")
- {
- BackupDistributionListRecipients($xmlroot_distributionlist,$obDistributionList);
- }
- }
- }
- }
-
- function BackupDomainAliases(&$p_xmlroot,&$p_domain)
- {
- global $output;
-
- $output[] = array("log" =>"Backing up aliases");
- $obAliases = $p_domain->Aliases();
- $Count = $obAliases->Count();
- if($Count)
- {
- $xmlroot_aliases = &$p_xmlroot->createChild("Aliases");
- $xmlroot_aliases->attribute("count",$Count);
- for ($i = 0; $i < $Count; $i++)
- {
- $obAlias = $obAliases->Item($i);
-
- $xmlroot_alias = &$xmlroot_aliases->createChild("Alias");
- $xmlroot_alias->attribute("id",($i+1));
- $xmlroot_aliases_elm = &$xmlroot_alias->createChild("Active");
- $xmlroot_aliases_elm->text(($obAlias->Active == true ? 1 : 0));
- $xmlroot_aliases_elm = &$xmlroot_alias->createChild("Name");
- $xmlroot_aliases_elm->text($obAlias->Name);
- $xmlroot_aliases_elm = &$xmlroot_alias->createChild("Type");
- $xmlroot_aliases_elm->text(intval($obAlias->Type));
- $xmlroot_aliases_elm = &$xmlroot_alias->createChild("Value");
- $xmlroot_aliases_elm->text($obAlias->Value);
- }
- }
- }
-
- function BackupAccounts(&$p_xmlroot,&$p_domain)
- {
- global $output;
-
- $output[] = array("log" => "Backing up accounts");
- $obAccounts = $p_domain->Accounts();
- $accountcount = $obAccounts->Count();
- if($accountcount)
- {
- $xmlroot_Accounts = &$p_xmlroot->CreateChild("Accounts");
- $xmlroot_Accounts->attribute("count",$accountcount);
- for($i = 0; $i < $accountcount; $i++)
- {
- $obAccount = $obAccounts->Item($i);
-
- $output[] = array("log" => "Backing up account : " . $obAccount->Address);
-
- $xmlroot_Account = &$xmlroot_Accounts->CreateChild("Account");
- $xmlroot_Account->attribute("id",$i+1);
-
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("Active");
- $xmlroot_Account_elm->text(($obAccount->Active == true ? 1 : 0));
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("ADDomain");
- $xmlroot_Account_elm->text($obAccount->ADDomain);
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("Address");
- $xmlroot_Account_elm->text($obAccount->Address);
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("IsAD");
- $xmlroot_Account_elm->text(($obAccount->IsAD == true ? 1 : 0));
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("Password");
- $xmlroot_Account_elm->text($obAccount->Password);
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("ADUserName");
- $xmlroot_Account_elm->text($obAccount->ADUserName);
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("MaxSize");
- $xmlroot_Account_elm->text($obAccount->MaxSize);
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("VacationMessageIsOn");
- $xmlroot_Account_elm->text(($obAccount->VacationMessageIsOn == true ? 1 : 0));
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("VacationSubject");
- $xmlroot_Account_elm->text($obAccount->VacationSubject);
- $xmlroot_Account_elm = &$xmlroot_Account->createChild("VacationMessage");
- $xmlroot_Account_elm->text(htmlentities($obAccount->VacationMessage));
- }
- }
- else
- {
- $output[] = array("log" => "No accounts to backup for domain : " . $p_domain->Name);
- }
- }
-
-
- function BackupSettings(&$p_xmlroot,&$p_baseapp)
- {
- global $output;
- $output[] = array("log" => "Backing up settings");
- $obSettings = $p_baseapp->Settings();
- $xmlroot_settings = &$p_xmlroot->createChild("Settings");
-
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("POP3Port");
- $xmlroot_settings_elm->text($obSettings->POP3Port);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("SMTPPort");
- $xmlroot_settings_elm->text($obSettings->SMTPPort);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("MaxSMTPConnections");
- $xmlroot_settings_elm->text($obSettings->MaxSMTPConnections);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("MaxPOP3Connections");
- $xmlroot_settings_elm->text($obSettings->MaxPOP3Connections);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("MirrorEMailAddress");
- $xmlroot_settings_elm->text($obSettings->MirrorEMailAddress);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("AllowSMTPAuthPlain");
- $xmlroot_settings_elm->text($obSettings->AllowSMTPAuthPlain);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("DenyMailFromNull");
- $xmlroot_settings_elm->text($obSettings->DenyMailFromNull);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("TarpitDelay");
- $xmlroot_settings_elm->text($obSettings->TarpitDelay);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("TarpitCount");
- $xmlroot_settings_elm->text($obSettings->TarpitCount);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("SMTPNoOfTries");
- $xmlroot_settings_elm->text($obSettings->SMTPNoOfTries);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("SMTPMinutesBetweenTry");
- $xmlroot_settings_elm->text($obSettings->SMTPMinutesBetweenTry);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("IMAPPort");
- $xmlroot_settings_elm->text($obSettings->IMAPPort);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("SMTPRelayer");
- $xmlroot_settings_elm->text($obSettings->SMTPRelayer);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("WelcomeSMTP");
- $xmlroot_settings_elm->text($obSettings->WelcomeSMTP);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("WelcomePOP3");
- $xmlroot_settings_elm->text($obSettings->WelcomePOP3);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("WelcomeIMAP");
- $xmlroot_settings_elm->text($obSettings->WelcomeIMAP);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("ServiceSMTP");
- $xmlroot_settings_elm->text($obSettings->ServiceSMTP);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("ServicePOP3");
- $xmlroot_settings_elm->text($obSettings->ServicePOP3);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("ServiceIMAP");
- $xmlroot_settings_elm->text($obSettings->ServiceIMAP);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("MaxDeliveryThreads");
- $xmlroot_settings_elm->text($obSettings->MaxDeliveryThreads);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("SendStatistics");
- $xmlroot_settings_elm->text($obSettings->SendStatistics);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("HostName");
- $xmlroot_settings_elm->text($obSettings->HostName);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("SMTPRelayerRequiresAuthentication");
- $xmlroot_settings_elm->text($obSettings->SMTPRelayerRequiresAuthentication);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("SMTPRelayerUsername");
- $xmlroot_settings_elm->text($obSettings->SMTPRelayerUsername);
- $xmlroot_settings_elm = &$xmlroot_settings->createChild("SMTPRelayerPort");
- $xmlroot_settings_elm->text($obSettings->SMTPRelayerPort);
-
- // Routes
- $obRoutes = $obSettings->Routes();
- if(is_object($obRoutes) && $obRoutes->Count())
- {
- $xmlroot_routes = &$xmlroot_settings->createChild("Routes");
- $xmlroot_routes->attribute("count",$obRoutes->Count());
- $Count = $obRoutes->Count();
- for ($i = 0; $i < $Count; $i++)
- {
- $obRoute = $obRoutes->Item($i);
- if($obRoute)
- {
- $xmlroot_route = &$xmlroot_routes->createChild("Route");
- $xmlroot_route->attribute("id",$i +1);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("DomainName");
- $xmlroot_routes_elm->text($obRoute->DomainName);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("TargetSMTPHost");
- $xmlroot_routes_elm->text($obRoute->TargetSMTPHost);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("TargetSMTPPort");
- $xmlroot_routes_elm->text($obRoute->TargetSMTPPort);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("NumberOfTries");
- $xmlroot_routes_elm->text($obRoute->NumberOfTries);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("MinutesBetweenTry");
- $xmlroot_routes_elm->text($obRoute->MinutesBetweenTry);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("AllAddresses");
- $xmlroot_routes_elm->text($obRoute->AllAddresses);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("RelayerRequiresAuth");
- $xmlroot_routes_elm->text($obRoute->RelayerRequiresAuth);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("RelayerAuthUsername");
- $xmlroot_routes_elm->text($obRoute->RelayerAuthUsername);
- $xmlroot_routes_elm = &$xmlroot_route->createChild("TreatSecurityAsLocalDomain");
- $xmlroot_routes_elm->text($obRoute->TreatSecurityAsLocalDomain);
-
- // Addresses
- $obAddresses = $obRoute->Addresses();
- if(is_object($obAddresses) && $obAddresses->Count())
- {
- $xmlroot_routeaddresses = &$xmlroot_route->createChild("RouteAddresses");
- $xmlroot_routeaddresses->attribute("count",$obAddresses->Count());
- $aCount = $obAddresses->Count();
- for ($j = 0; $j < $aCount; $j++)
- {
- $obAddress = $obAddresses->Item($j);
- $xmlroot_routeaddress = &$xmlroot_routeaddresses->createChild("RouteAddress");
- $xmlroot_routeaddress->attribute("id",$j+1);
- $xmlroot_routeaddress_elm = &$xmlroot_routeaddress->createChild("Address");
- $xmlroot_routeaddress_elm->text($obAddress->Address);
- }
- }
- }
- }
- }
- // IP Ranges
- $obSecurityRanges = $obSettings->SecurityRanges();
- if(is_object($obSecurityRanges) && $obSecurityRanges->Count())
- {
- $xmlroot_ranges = &$xmlroot_settings->createChild("IPRanges");
- $xmlroot_ranges->attribute("count",$obSecurityRanges->Count());
- $Count = $obSecurityRanges->Count();
- for ($i = 0; $i < $Count; $i++)
- {
- $obSecurityRange = $obSecurityRanges->Item($i);
-
- $xmlroot_range = &$xmlroot_ranges->createChild("Range");
- $xmlroot_range->attribute("id",$i+1);
- $xmlroot_range_elm = &$xmlroot_range->createChild("LowerIP");
- $xmlroot_range_elm->text($obSecurityRange->LowerIP);
- $xmlroot_range_elm = &$xmlroot_range->createChild("UpperIP");
- $xmlroot_range_elm->text($obSecurityRange->UpperIP());
- $xmlroot_range_elm = &$xmlroot_range->createChild("AllowSMTPConnections");
- $xmlroot_range_elm->text($obSecurityRange->AllowSMTPConnections);
- $xmlroot_range_elm = &$xmlroot_range->createChild("AllowPOP3Connections");
- $xmlroot_range_elm->text($obSecurityRange->AllowPOP3Connections);
- $xmlroot_range_elm = &$xmlroot_range->createChild("Priority");
- $xmlroot_range_elm->text($obSecurityRange->Priority);
- $xmlroot_range_elm = &$xmlroot_range->createChild("AllowIMAPConnections");
- $xmlroot_range_elm->text($obSecurityRange->AllowIMAPConnections);
- $xmlroot_range_elm = &$xmlroot_range->createChild("Name");
- $xmlroot_range_elm->text($obSecurityRange->Name);
- $xmlroot_range_elm = &$xmlroot_range->createChild("RequireAuthForDeliveryToLocal");
- $xmlroot_range_elm->text($obSecurityRange->RequireAuthForDeliveryToLocal);
- $xmlroot_range_elm = &$xmlroot_range->createChild("RequireAuthForDeliveryToRemote");
- $xmlroot_range_elm->text($obSecurityRange->RequireAuthForDeliveryToRemote);
- $xmlroot_range_elm = &$xmlroot_range->createChild("AllowDeliveryFromLocalToLocal");
- $xmlroot_range_elm->text($obSecurityRange->AllowDeliveryFromLocalToLocal);
- $xmlroot_range_elm = &$xmlroot_range->createChild("AllowDeliveryFromLocalToRemote");
- $xmlroot_range_elm->text($obSecurityRange->AllowDeliveryFromLocalToRemote);
- $xmlroot_range_elm = &$xmlroot_range->createChild("AllowDeliveryFromRemoteToLocal");
- $xmlroot_range_elm->text($obSecurityRange->AllowDeliveryFromRemoteToLocal);
- $xmlroot_range_elm = &$xmlroot_range->createChild("AllowDeliveryFromRemoteToRemote");
- $xmlroot_range_elm->text($obSecurityRange->AllowDeliveryFromRemoteToRemote);
- }
- }
-
- // Logging
- $xmlroot_logging = &$xmlroot_settings->createChild("Logging");
- $obLogging = $obSettings->Logging();
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("Enabled");
- $xmlroot_logging_elm->text($obLogging->Enabled);
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("LogSMTP");
- $xmlroot_logging_elm->text($obLogging->LogSMTP);
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("LogPOP3");
- $xmlroot_logging_elm->text($obLogging->LogPOP3);
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("LogTCPIP");
- $xmlroot_logging_elm->text($obLogging->LogTCPIP);
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("LogApplication");
- $xmlroot_logging_elm->text($obLogging->LogApplication);
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("Device");
- $xmlroot_logging_elm->text($obLogging->Device);
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("LogFormat");
- $xmlroot_logging_elm->text($obLogging->LogFormat);
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("LogDebug");
- $xmlroot_logging_elm->text($obLogging->LogDebug);
- $xmlroot_logging_elm = &$xmlroot_logging->createChild("LogIMAP");
- $xmlroot_logging_elm->text($obLogging->LogIMAP);
- //$xmlroot_logging_elm = $xmlroot_logging->createChild("EnableIPCLogging");
- //$xmlroot_logging_elm->text($obLogging->EnableIPCLogging);
-
- // Antivirus
- $obAntivirus = $obSettings->AntiVirus();
- $xmlroot_antivirus = &$xmlroot_settings->createChild("Antivirus");
- $xmlroot_antivirus_elm = &$xmlroot_antivirus->createChild("ClamWinEnabled");
- $xmlroot_antivirus_elm->text($obAntivirus->ClamWinEnabled);
- $xmlroot_antivirus_elm = &$xmlroot_antivirus->createChild("ClamWinExecutable");
- $xmlroot_antivirus_elm->text($obAntivirus->ClamWinExecutable);
- $xmlroot_antivirus_elm = &$xmlroot_antivirus->createChild("ClamWinDBFolder");
- $xmlroot_antivirus_elm->text($obAntivirus->ClamWinDBFolder);
- $xmlroot_antivirus_elm = &$xmlroot_antivirus->createChild("Action");
- $xmlroot_antivirus_elm->text($obAntivirus->Action);
- $xmlroot_antivirus_elm = &$xmlroot_antivirus->createChild("NotifyReceiver");
- $xmlroot_antivirus_elm->text($obAntivirus->NotifyReceiver);
- $xmlroot_antivirus_elm = &$xmlroot_antivirus->createChild("NotifySender");
- $xmlroot_antivirus_elm->text($obAntivirus->NotifySender);
- }
- ?>